﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" AutoEventWireup="true" CodeBehind="SearchResults.aspx.cs" Inherits="LizzabethBrownRealEstate.Views.Users.SearchResults" %>
<%@ Import Namespace="LizzabethBrownRealEstate.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="server">


    <% LBRDataContext dc = new LBRDataContext(); %>
    <% IQueryable<RealEstateProperty> props = (IQueryable<RealEstateProperty>)ViewData["PropertyList"]; %>
    <% if (props.AsEnumerable<RealEstateProperty>().Count<RealEstateProperty>() == 0)
       { %>
            <div style="height:200px; text-align:center; padding-top:50px;">No results to display</div>
    <%} %>
    <table>
    <% foreach (RealEstateProperty p in props.AsEnumerable<RealEstateProperty>())
       { %>
            <tr>
                <td >
                    <% if (p.Photos.Count > 0)
                       {
                           object propId = new { propertyId = p.PropertyId }; 
                           Photo f = p.Photos.Where<Photo>(foto => foto.Deleted == false).Take<Photo>(1).SingleOrDefault<Photo>(); %>
                       
                    <a href="<%= Url.Action("ViewProperty", "Home", propId ) %>"><img class="featuredProperty" src='../Repository/<%= f.FileName %>' height="120" width="120" alt="" /></a>
                    <% }
                       else
                       { %>
                    <label style="text-align:center; font-size:.7em">No photo available</label>
                    <%} %>
                </td>
                <td style="text-align:left">
                    <ul style="text-align:left">
                        <li>Location:&nbsp;<%= p.Location.Name %></li>
                        <li>Price:&nbsp;<%= String.Format("{0:C}", p.Price) %></li>
                    </ul>
                </td>
            </tr>
                
    <%} %>
    </table>

</asp:Content>
